<?php

class Application_Form_Product extends Zend_Form {
    
    public function init() {
        $this->setName('Product');
        
        $product_id = new Zend_Form_Element_Hidden('product_id');
        $product_date_added = new Zend_Form_Element_Hidden('product_date_added');
        $product_date_modified = new Zend_Form_Element_Hidden('product_last_modified');
        $manufactures_id = new Zend_Form_Element_Hidden('manufactures_id');
        
        $product_quantity = new Zend_Form_Element_Text('product_quantity');
                $product_quantity->setLabel('Số lượng :')
                                 ->setRequired(true)
                ->addFilters(array('StripTags', 'StringTrim', 'Int'))
                ->addValidator('NotEmpty');
            
        $product_model = new Zend_Form_Element_Text('product_model');
                $product_model->setLabel('Kiểu :')
                        ->setRequired(true);
                
        $product_name = new Zend_Form_Element_Text('product_name');
                $product_name->setLabel('Tên :')
                        ->setRequired(true);
                
        $product_description = new Zend_Form_Element_Textarea('product_description');
                $product_description->setLabel('Mô tả :');
                 
        $product_image = new Zend_Form_Element_File('product_image');
                $product_image->setLabel('Hình ảnh :')
                              ->setDestination(ROOT_PUBLIC_MEDIA_UPLOAD_USERIMAGE);
                $product_image->addValidator('Count', false, 1); // only one file
                $product_image->addValidator('Size', false, 1024000); //500Kb
                $product_image->addValidator('Extension', false, 'jpg,png,gif'); // file extention
                
        $product_price = new Zend_Form_Element_Text('product_price');
                $product_price->setLabel('Giá :')
                        ->setRequired(true);
                $product_price->addFilters(array('StripTags', 'StringTrim', 'Int'))
                              ->addValidator('NotEmpty');
                
        $product_weight = new Zend_Form_Element_Text('product_weight');
                $product_weight->setLabel('Trọng lượng :');
                $product_weight->addValidator('NotEmpty');
         
        $product_status = new Zend_Form_Element_Text('product_status');
                $product_status->setLabel('Trạng thái :');
                $product_status->addFilters(array('StripTags', 'StringTrim'))
                               ->addValidator('NotEmpty');    
                
        $btn_submit = new Zend_Form_Element_Submit('submit');
        $btn_submit->setAttrib('id', 'submit');
        $btn_submit->setlabel('Đồng ý');

        $btn_cancel = new Zend_Form_Element_Submit('cancel');
        $btn_cancel->setAttrib('id', 'cancel');
        $btn_cancel->setLabel('Hủy bỏ');
        
        $this->addElements(array($product_name, $product_model, $product_quantity,
                                 $product_description, $product_price, $product_weight, $product_status, $product_image,
                                 $product_id, $product_date_added, $product_date_modified, $manufactures_id, $btn_submit, $btn_cancel
        ));
    }
}